<script type="text/x-template" id='my-atm'>
    <div>
        <div class="weui-tab">
            <div class="weui-navbar">
                <div @click="tabname='atm'" :class="tabname=='atm'?'weui-bar__item_on':''" class="weui-navbar__item ">
                    申请提现
                </div>
                <div @click="tabname='atmlog'" :class="tabname=='atmlog'?'weui-bar__item_on':''" class="weui-navbar__item">
                    提现记录
                </div>
            </div>
            <div v-if="tabname=='atm'" class="weui-tab__panel">
                <div style="margin-top:0;" class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">我的余额</label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" value="{$_W['member']['credit2']}" disabled>
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">提现金额</label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" v-model="atm.money" type="number" placeholder="请输入提现金额">
                        </div>
                    </div>
                </div>
                <div class="weui-btn-area">
                    <a @click="tixian" class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">确定</a>
                </div>
            </div>

            <div v-if="tabname=='atmlog'" class="weui-tab__panel">
                <div class="weui-panel">
                  <!--   <div class="weui-panel__hd">文字列表附来源</div> -->
                    <template v-for="item in atmlog.list">
                        <div class="weui-panel__bd">
                            <div class="weui-media-box weui-media-box_text">
                                <h4 class="weui-media-box__title">金额:{{item.money}}</h4>
                                <p class="weui-media-box__desc">
                                    提交时间:{{item.create_time}}
                                </p>
                                <ul class="weui-media-box__info">
                                    <li class="weui-media-box__info__meta">{{item.status==0?'待处理':'已打款'}}</li>
                                    <li v-if="item.status==1" class="weui-media-box__info__meta">打款时间:{{item.check_time}}</li>
                                    <!-- 
                                    <li class="weui-media-box__info__meta weui-media-box__info__meta_extra">其它信息</li> -->
                                </ul> 
                            </div>
                        </div>
                    </template>
                    <div v-if="atmlog.page>0" class="weui-panel__ft">
                        <a @click="getAtmLog" href="javascript:void(0);" class="weui-cell weui-cell_access weui-cell_link">
                            <div class="weui-cell__bd">查看更多</div>
                            <span class="weui-cell__ft"></span>
                        </a>    
                    </div>
                </div>
            </div>

        </div>
        
    </div>
</script>
<script>
    var myAtm = Vue.component('my-atm', {
        template: '#my-atm',
        data: function (){
            return {
                atm: {
                    money:''
                },
                tabname: 'atm',
                atmlog:{
                    page:1,
                    list:[]
                }
            }
        },
        created: function () {
            this.getAtmLog();
        },
        methods:{
            tixian:function () {
                var self = this;
                if(!this.atm.money || this.atm.money<=0) {
                    weui.alert('请正确填写提现金额');
                    return false;
                }
                var cfm = weui.confirm('确定提现吗?',function(){
                    http({
                        url: newBaseUrl + 'tixian',
                        method: 'post',
                        data:self.atm
                    }).then(function(res){
                        res = res.data;
                        if(res.ret==0) {
                            cfm.hide(function(){
                                weui.alert(res.message,function(){
                                    location.reload();
                                });
                            });
                        }else{
                            cfm.hide(function(){
                                weui.alert(res.message);
                            });
                        }
                    });
                    return false;
                })
            },
            getAtmLog: function () {
                var self = this;
                http({
                    url: newBaseUrl + 'getatmlog&page='+self.atmlog.page,
                }).then(function(res){
                    res = res.data;
                    if(res.ret==0) {
                        for(var i=0;i<res.data.length;i++) {
                            self.atmlog.list.push(res.data[i]);
                        }
                        self.atmlog.page++;
                    }else{
                        self.atmlog.page = 0;
                    }
                })
            }
        }
    })
</script>
